<%--
  Created by IntelliJ IDEA.
  User: tang
  Date: 2022/5/27
  Time: 14:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>信息列表</title>
    <style>
        table{
            border: 1px solid plum;
            width: 1000px;
            margin: 10px auto;
            text-align: center;
            border-collapse: collapse;
        }
        tr{
            border: 1px solid plum;
            height: 50px;
            text-align: center;
        }
        th{
            border: 1px solid plum;
        }
        h2{
            text-align: center;
        }

    </style>
</head>
<body>
<h2>信息列表</h2>
<p>欢迎[${loginUser}]</p>
<table>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>生日</th>
        <th>性别</th>
        <th>职业</th>
        <th>住所</th>
        <th>电话</th>

    </tr>
    <%--    展示域中的数据--%>

    <c:forEach items="${list}" var="list">
        <tr>
            <td>${list.id}</td>
            <th>${list.name}</th>
            <th>${list.birthday}</th>
            <th>${list.gender}</th>
            <th>${list.career}</th>
            <th>${list.address}</th>
            <th>${list.mobile}</th>
            <th><a href="detail?profileId=${list.id}" >明细</a>
                <a href="update?profileId=${list.id}" >修改</a>
            </th>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="8">
            <%--            pageContext.request.contextPath可以获取到 http://localhost:8080/bookList--%>
            <a href="<c:url value='/list?pageIndex=1'></c:url> ">首页</a>

            <%--            如果当前在第一页,不能点击上一页--%>
            <c:if test="${page.pageIndex > 1}">

                <a href="<c:url value='/list?pageIndex=${page.pageIndex-1}'></c:url> ">上一页</a>
            </c:if>

            <%--            点击上一页,判断如果当前页面是第一页,不允许点击上一页--%>
            <c:if test="${page.pageIndex == 1}">
                <a>上一页</a>
            </c:if>

            <%--点击下一页,需要判定,当前页一定小于总页数--%>
            <c:if test="${page.pageIndex < page.totalPages}">
                <a href="<c:url value='/list?pageIndex=${page.pageIndex+1}'></c:url> ">下一页</a>
            </c:if>

            <%--            点击下一页,判断如果当前页等于总页数,不允许点击下一页--%>
            <c:if test="${page.pageIndex == page.totalPages}">
                <a>下一页</a>
            </c:if>

            <%--            尾页 = 最后一页也就是总页数--%>
            <a href="<c:url value='/list?pageIndex=${page.totalPages}'></c:url> ">尾页</a>
        </td>
    </tr>
</table>
</body>
</html>
